<?php

$mysql_support = function_exists('mysqli_connect') ? 'ON' : 'OFF';
$result = array();
//检查mysql
$result["mysql"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (function_exists('mysqli_connect')) {
    $mysql_support = 'ON';
    $mysql_ver_class = 'OK';
} else {
    $mysql_support = 'OFF';
    $mysql_ver_class = 'warning';
    $result["mysql"] = ["target" => "OK", "actual" => "No", "msg" => "请开启Mysql支持"];
}
$result["php_version"] = ["target" => "6.0.0+", "actual" => "6.0.0+", "msg" => "OK"];
if (PHP_VERSION < '6.0.0') {
    $result["php_version"] = ["target" => "6.0.0+", "actual" => "6.0.0+", "msg" => "php 版本过低,php 版本需大于或等于6.0.0'"];
}
$function = 'OK';
$fstr = "";
$result["file_put_contents"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('file_put_contents')) {
    $result["file_put_contents"] = ["target" => "OK", "actual" => "NO", "msg" => "空间不支持file_put_contents函数，系统无法写文件"];
}
$result["email"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('fsockopen') && !function_exists('pfsockopen')
    && !function_exists('stream_socket_client')) {
    $result["email"] = ["target" => "OK", "actual" => "OK", "msg" => "空间不支持fsockopen，pfsockopen,stream_socket_client函数，系统邮件功能不能使用。请至少开启其中一个"];
}
$result["copy"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('copy')) {
    $result["copy"] = ["target" => "OK", "actual" => "NO", "msg" => "空间不支持copy函数，无法上传文件"];
}

$result["gd"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!get_extension_funcs('gd')) {
    $result["gd"] = ["target" => "OK", "actual" => "OK", "msg" => "空间不支持gd模块，图片打水印和缩略生成功能无法使用"];
}
$result["gzinflate"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('gzinflate')) {
    $result["gzinflate"] = ["target" => "OK", "actual" => "OK", "msg" => "空间不支持gzinflate函数，无法在线解压ZIP文件。（无法通过后台上传模板和数据备份文件）"];
}
$result["fopen"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('fopen')) {
    $result["fopen"] = ["target" => "OK", "actual" => "OK", "msg" => "空间不支持fopen函数，无法在线解压ZIP文件。（无法通过后台上传模板和数据备份文件）"];
}
$result["ini_set"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('ini_set')) {
    $result["ini_set"] = ["target" => "OK", "actual" => "OK", "msg" => "空间不支持ini_set函数，系统无法正常包含文件，导致后台会出现空白现象"];
}
$result["mb_strlen"] = ["target" => "OK", "actual" => "OK", "msg" => "OK"];
if (!function_exists('mb_strlen')) {
    $result["mb_strlen"] = ["target" => "OK", "actual" => "OK", "msg" => "空间不支持mb_strlen函数，系统无法正常包含文件，会导致前台显示不全"];
}

?>
<!DOCTYPE html >
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>LeeCms系统安装</title>
    <link rel="stylesheet" href="/<?php echo $basepath ?>/install/assert/install.css"/>
    <script type="text/javascript" src="/<?php echo $basepath ?>/assert/js/jquery.js"></script>
</head>
<body>
<div class="header">
    <div class="logo">LeeCms</div>
    <div class="step">
        <div class="line"></div>
        <ul class="step_num">
            <li class=""><span class="num">1</span>
                <p class="name">阅读安装协议</p></li>
            <li class="current"><span class="num">2</span>
                <p class="name">检测安装环境</p></li>
            <li class=""><span class="num">3</span>
                <p class="name">可写检测</p></li>
            <li class=""><span class="num">4</span>
                <p class="name">开始安装</p></li>
            <li class=""><span class="num">5</span>
                <p class="name">完成安装</p></li>
        </ul>

    </div>
</div>
<div class="content">
    <table border="1" cellpadding="true" cellspacing="true">
        <thead>
        <tr>
            <th>检查模块</th>
            <th>LeeCms期望结果</th>
            <th>系统实际检测结果</th>
            <th>描述</th>
        </tr>
        </thead>
        <?php
        $flag = true;
        foreach ($result as $key => $val) {
            if ($val["msg"] != "OK") {
                $flag = false;
            }
            ?>
            <tr>
                <td><?php echo $key ?></td>
                <td width="120"><?php echo $val["target"] ?></td>
                <td style="width:120px;font-weight: bold;<?php echo $val["msg"] != "OK" ? "color:red" : "color:green"; ?>"><?php echo $val["actual"] ?></td>
                <td><?php echo $val["msg"] ?></td>
            </tr>
        <?php } ?>

        </tbody>
    </table>
</div>
<script type="text/javascript">
    function submit_next() {
        let flag = "<?php echo $flag;?>";
        if (flag !== "1"&&flag!=="true") {
            alert("当前环境不支持LeeCms安装,请先配置环境");
            return false;
        }
        window.location.href = "?step=step3";
    }
</script>
<div class="btn_wrap">
    <input name=""
           type="button"
           class="next_btn"
           value="下一步"
           onclick="submit_next()"/><input
            name="" type="button" class="prev_btn" value="上一步" onclick="window.location.href='?step'"/>
    <div class="cl"></div>
</div>
<div class="footer">Powered By LeeCms 版权所有 &copy; 2020-2022, All right reserved.</div>
</body>
</html>